﻿using ETA.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace ETA.IRepository
{
    /// <summary>
    /// 仓储层基类接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TPrimaryKey"></typeparam>
    public interface IRepository<TEntity, in TPrimaryKey>  where TEntity : AEntity
    {
        // Methods
        int Count();
        int Count(Expression<Func<TEntity, bool>> predicate);
        void Delete(TEntity entity);
        void Delete(TPrimaryKey id);
        void LogincDelete(TPrimaryKey id);
        TEntity FirstOrDefault(TPrimaryKey key);
        TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate);
        TEntity Get(TPrimaryKey key);
        IQueryable<TEntity> GetAll();
        List<TEntity> GetAllList();
        List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate);
        TEntity Insert(TEntity entity);
        TEntity Load(TPrimaryKey key);
        long LongCount();
        long LongCount(Expression<Func<TEntity, bool>> predicate);
        T Query<T>(Func<IQueryable<TEntity>, T> queryMethod);
        TEntity Single(Expression<Func<TEntity, bool>> predicate);
        TEntity Update(TEntity entity);
        TEntity Merge(TEntity entity);
        string GenerateNo(string firestChar, int noType);
    }
}
